package com.teach.api;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.teach.R;
import com.teach.service.SmsMessageService;

@RestController
@RequestMapping("/api")
public class SmsApi {
	
	private final static Logger log = LoggerFactory.getLogger(SmsApi.class);
	
	@Autowired
	private SmsMessageService service;

	@GetMapping("sms")
	public R sendSms(String tel) {
		try {
			service.send(tel);
			return R.ok();
		}catch (Exception e) {
			log.warn("短信发生失败",e);
			return R.error().setMessage(e.getMessage());
		}
		
	}
}
